package com.ecfront.dao.impl;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.ecfront.dao.LinkDAO;
import com.ecfront.pojo.Link;


/**
 * @version 1.0
 * @author www.ecfrom.com
 */

public class LinkDAOImpl extends HibernateDaoSupport implements LinkDAO {

	protected void initDao() {}


	public void save(Link transientInstance) {
		getHibernateTemplate().saveOrUpdate(transientInstance);
	}


	public void delete(Link persistentInstance) {
		getHibernateTemplate().delete(persistentInstance);
	}

	public Link findById(java.lang.Integer id) {
		Link instance = (Link) getHibernateTemplate().get(
					"com.ecfront.pojo.Link", id);
		return instance;
	}


	public List findByExample(Link instance) {
		List results = getHibernateTemplate().findByExample(instance);
		return results;
	}

	public List findByProperty(String propertyName, Object value) {
		String queryString = "from Link as model where model."
					+ propertyName + "= ?";
		return getHibernateTemplate().find(queryString, value);
	}


	public List findByIname(Object iname) {
		return findByProperty(INAME, iname);
	}

	public List findByIimagUrl(Object iimagUrl) {
		return findByProperty(IIMAG_URL, iimagUrl);
	}

	public List findByIwordUrl(Object iwordUrl) {
		return findByProperty(IWORD_URL, iwordUrl);
	}

	public List findByIlevel(Object ilevel) {
		return findByProperty(ILEVEL, ilevel);
	}

	public List findAll() {
		String queryString = "from Link";
		return getHibernateTemplate().find(queryString);
	}

	public static LinkDAO getFromApplicationContext(ApplicationContext ctx) {
		return (LinkDAO) ctx.getBean("LinkDAO");
	}
}